home *** CD-ROM | disk | FTP | other *** search
- name JREBOOT
- page 60,132
- title 'JREBOOT - Reboot JBOOT.BIN, Version 3.41'
-
- COMMENT ~
-
- This program reboots an IBM PC/XT which has a TallTree JRAM3 card
- and the JBOOT.BIN device driver. Its usage is:
- JREBOOT Warm reset
- JREBOOT W or JREBOOT w Warm reset
- JREBOOT - ROM reset
- JREBOOT R or JREBOOT r ROM reset
- JREBOOT C or JREBOOT c Cold reboot
- JREBOOT K or JREBOOT k Cold reboot
-
- If DOS is earlier than version 2, The NUL device is not loaded or
- JBOOT device is not loaded, the program exits with return code 1. If
- the usage is wrong, it exits with return code 2. While JBOOT should
- never return, if it does, the program exits with return code 3.
-
- It is very sensitive to the exact version of JBOOT.BIN. To check it
- for your software, assemble and list JBOOT.ASM from the TallTree disk,
- then compare the offsets of the labels warmreset, coldboot and romreset
- to their values as constants below. If they are different, change the
- constants.
-
- Technically, this is very dirty code. Its main function is to
- synthesize a far call into $JBOOT, the JBOOT device driver. Since I
- can not find an 8088 instruction which gives an indirect far call, I
- have been forced to treat the rebooting instruction as data. Thus the
- "DB 9A" and the double word reboot very near the end of the code segment
- becomes a far call to the proper point in JBOOT.BIN.
-
- ACKNOWLEDGEMENT. I have marked sections of code which I have copied
- from DEV11.ARC, which is a program to list device drivers, Copywrite (c)
- 1984 by Ray Duncan and modified in 1986 by Brian J. Larson for DOS 3.2.
- Mr.Duncan has given me permission to distribute this program.
-
- ~
-
- warmreset EQU 03E4H ; Offset of label in JBOOT.BIN
- coldboot EQU 0455H ; Offset of label in JBOOT.BIN
- romreset EQU 048AH ; Offset of label in JBOOT.BIN
-
- ht EQU 9 ; Horizontal tab
-
- ; Code from DEV11 starts here
- cr equ 0dh ;ASCII carriage return
- lf equ 0ah ;ASCII line feed
- blank equ 20h ;ASCII space code
- eom equ '$' ;end of string marker
-
-
- cseg segment para public 'CODE'
-
- assume cs:cseg,ds:data,es:data,ss:stack
-
- ; Code from DEV11 temporarily ends
-
- jreboot PROC FAR ;entry point from PC-DOS
-
- MOV SI,80H ; Offset of number of characters on
- ; command line
- LODSB ; Number of characters on command line
- ; SI points to first character if there
- ; are any
- OR AL,AL ; Are there any?
- JZ set_warmreset ; No. Set warm reset.
- XOR AH,AH ; Convert byte to word
- MOV CX,AX ; Number of characters => CX
- check_white:
- LODSB ; Command line character => AL
- ; Increment SI
- CMP AL,blank ; Is the character a space?
- JE check_white ; Get next character
- CMP AL,ht ; Is it a horizontal tab?
- JE check_white ; Get next character
- CMP AL,cr ; Is it a carriage return?
- JE set_warmreset ; Yes. Only white characters on
- ; command line.
- SUB SI,81H ; Number of characters read
- CMP SI,CX ; Is this the last character?
- JNZ usage_error ; No. Print error message and exit.
- CMP AL,'-' ; Is it a dash?
- JE set_romreset ; Yes. Set ROM reset
- AND AL,5FH ; If it is a letter, set it to
- ; upper case
- CMP AL,'W' ; Is it a W?
- JE set_warmreset ; Yes. Set warm reset
- CMP AL,'R' ; Is it a R?
- JE set_romreset ; Yes. Set ROM reset
- CMP AL,'K' ; Is it a K?
- JE set_coldboot ; Yes. Set cold reboot
- CMP AL,'C' ; Is it a K?
- JE set_coldboot ; Yes. Set cold reboot
-
- usage_error:
- MOV AX,data ; Establish addressability
- MOV DS,AX
- MOV AH,40H ; DOS write handle function
- MOV BX,2 ; Handle for Standard Error
- MOV CX,usage_length ; Number of characters to write
- MOV DX,OFFSET usage ; Pointer to usage message
- INT 21H ; Write it
- MOV AX,4C02H ; Exit with return code 2
- INT 21H
-
- set_warmreset:
- MOV BX,warmreset ; Offset of warm reset in JBOOT
- JMP SHORT set_offset_end
-
- set_romreset:
- MOV BX,romreset ; Offset of ROM reset in JBOOT
- JMP SHORT set_offset_end
-
- set_coldboot:
- MOV BX,coldboot ; Offset of cold boot in JBOOT
- JMP SHORT set_offset_end ; Defensive programming
-
- set_offset_end:
- MOV WORD PTR CS:reboot,BX ; Offset in JBOOT to junp to
-
- MOV AX,data ; Establish addressibility
- MOV DS,AX
- MOV ES,AX
-
- ; Code from DEV11 restarts here. I added a few SHORT's to the jmp
- ; instructions. LP
- mov ah,30h ;check version of PC-DOS.
- int 21h
- cmp al,2
- jae dev1 ;proceed, DOS 2.0 or greater.
- mov dx,offset msg2 ;DOS 1.x --- print error message.
- jmp dev6
-
- dev1: mov cx,ax ;save DOS version number.
- mov ah,15 ;now try and open the "NUL" device.
- mov dx,offset nulfcb
- int 21h
- or al,al ;opened successfully?
- jz dev2 ;yes, jump.
- mov dx,offset msg1 ;no, print error msg and exit.
- jmp SHORT dev6
-
- dev2: ;Pick up double pointer to device
- ;driver chain out of reserved
- ;area in fcb. This area is mapped
- ;differently in DOS 2.x and DOS 3.x.
- cmp cl,2 ;is this DOS 2.x?
- ja dev3 ;no, jump.
- mov bx,word ptr nulfcb+25
- mov es,word ptr nulfcb+27
- jmp SHORT dev4
-
- dev3: ;come here if DOS 3.0 or greater.
- cmp ch,2 ;compare minor - DOS 3.2 or greater?
- jae dev32 ;yes, jump.
- mov bx,word ptr nulfcb+26
- mov es,word ptr nulfcb+28
- jmp SHORT dev4
-
- dev32: ;come here if DOS 3.2 or above
- mov bx,48h ;value at nulfcb+26 is C2h but NUL is at 48h
- mov es,word ptr nulfcb+28
-
- dev4:
- ;pick up addr of next header.
- les bx,dword ptr es:[bx]
- cmp bx,-1 ;found last one yet?
-
- ; Restarted code from DEV11 temporarily ends here
-
- JE no_jboot ; JBOOT device driver is not loaded
- TEST ES:[BX+4],08000H ; Is this a character device? Bit
- ; 15 of attribute word is set if yes.
- JZ dev4 ; No. Get next header
- MOV SI,OFFSET jboot_name ; "$JBOOT "
- MOV DI,BX ; Offset of start of header
- ADD DI,10 ; Offset of device name
- MOV CX,8 ; Number of characters in name
- REPE CMPSB ; Is this the JBOOT device driver
- JNE dev4 ; No. Get next header.
- MOV AX,ES ; Segment of JBOOT device driver
- MOV WORD PTR CS:reboot+2,AX
- ; Save for FAR CALL
- ADD WORD PTR CS:reboot,BX ; Offset of JBOOT device driver to
- ; offset of entry
- PUSHF ; To fake an interrupt
-
- ; This is the data which becomes the far call to the interior of JBOOT.BIN.
- ; Theoretically, there should be no return, because JBOOT should reboot
- DB 9AH ; Op code for Intersegment FAR CALL
- reboot DD (?) ; Offset, segment in JBOOT to reboot
-
- MOV AX,data ; This is the impossible return. If
- ; it happens, you had better
- ; reestablish addressibility
- MOV DS,AX
- MOV AH,40H ; Write function for handles
- MOV BX,01 ; Handle for Standard Error
- MOV CX,jboot_returns_msg_length
- ; Number of bytes to write
- MOV DX,OFFSET jboot_returns_msg
- ; Offset of error message
- INT 21H ; Write it
- MOV AX,4C03H ; Exit with return code 3
- INT 21H
- no_jboot:
- MOV DX,OFFSET no_jboot_msg
- ; No JBOOT message
- JMP SHORT dev6 ; Defensive programming
-
- ; Code from DEV11 restarts here
-
- dev6: mov ah,9 ;print the string whose address
- int 21h ;is in DX.
-
- ; Restarted code from DEV11 temporarily ends here
-
- MOV AX,4C01H ; Exit with return code 1
- INT 21H
-
- jreboot ENDP
-
- ; Code from DEV11 restarts here
-
- cseg ends
-
-
- data segment para public 'DATA'
-
- msg1 db cr,lf
- db 'Failed to open NUL device.'
- db cr,lf,eom
-
- msg2 db cr,lf
- db 'Requires DOS version 2 or greater.'
- db cr,lf,eom
-
- ; Restarted code from DEV11 temporarily ends here
-
- no_jboot_msg DB cr,lf
- DB "JBOOT device driver is not loaded"
- DB cr, lf, eom
-
- usage DB cr, lf, " This program reboots an IBM PC/XT which "
- DB "has a TallTree JRAM3 card", cr, lf
- DB "and the JBOOT.BIN device driver. Its usage is:", cr, lf
- DB " JREBOOT Warm reset", cr, lf
- DB " JREBOOT W or JREBOOT w Warm reset", cr, lf
- DB " JREBOOT - ROM reset", cr, lf
- DB " JREBOOT R or JREBOOT r ROM reset", cr, lf
- DB " JREBOOT C or JREBOOT c Cold reboot", cr, lf
- DB " JREBOOT K or JREBOOT k Cold reboot", cr, lf
- usage_length = $ - OFFSET usage
-
- jboot_returns_msg DB cr,lf
- DB "JBOOT should have rebooted instead of returning here"
- DB cr,lf
- jboot_returns_msg_length = $ - OFFSET jboot_returns_msg
- jboot_name DB "$JBOOT " ; Name of JBOOT device driver
-
- ; Code from DEV11 restarts here
- ;fcb to open NUL device
- nulfcb db 0 ;drive
- db 'NUL' ;name of NUL device
- db 8 dup (' ')
- db 25 dup (0)
- data ends
-
-
- stack segment para stack 'STACK'
- db 64 dup (?)
- stack ends
-
- ; Code from DEV11 ends here
-
- END jreboot